#include "StdAfx.h"
#include "sound.h"


// Define global for sound engine (else it will be created each time we call it to play a sound
irrklang::ISoundEngine* engine = NULL;
irrklang::ISound* sndBG = NULL;



void setupSound() {
		
	// Init sound
	engine = irrklang::createIrrKlangDevice();

}

void cleanupSound() {
// Close sound engine
	engine->drop();
		
}


void playSound(char* file) {
	// Play specified sound
	engine->play2D(file, false);
}

void backgroundSound(bool pause) {
	// Keeps the background sound running
	if (sndBG == NULL) {
		sndBG = engine->play2D("../../sounds/back.mp3", true, false, true); 
		sndBG->setVolume(0.2);
	} else {
		if (pause)
			sndBG->setVolume(0.0);
		else
			sndBG->setVolume(0.2);
	}
}